/**
* Copyright (c) By zengqh.
*
* This program is just for fun or demo, in the hope that it  
* will be useful, you can redistribute it and/or modify freely.
*
* Time: 2012/12/16
* File: EnnGPUObject.h
* Blog: http://www.cnblogs.com/zengqh/
**/

#ifndef EnnGPUObject_h__
#define EnnGPUObject_h__

#include "EnnPrerequisites.h"

namespace Enn
{
	class RenderSystem;

	class GPUObjectHandle : public RenderSysAlloc
	{
	public:
		GPUObjectHandle();
		virtual ~GPUObjectHandle();
	};


	class GPUObject : public RenderSysAlloc
	{
		/// Construct with graphics subsystem pointer.
		GPUObject(RenderSystem* renderSys);
		/// Destruct. Remove from the graphics subsystem.
		virtual ~GPUObject();

		/// Release default pool resources.
		virtual void onDeviceLost() {}
		/// Recreate default pool resources.
		virtual void onDeviceReset() {}
		/// Unconditionally release the GPU resource.
		virtual void release() {}

		/// Clear the data lost flag.
		void clearDataLost();

		/// Return the graphics subsystem.
		Graphics* getRenderSys() const { return renderSys_; }

		GPUObjectHandle* getHandle() const { return rawHandle_; }

	protected:
		RenderSystem*		renderSys_;
		GPUObjectHandle*	rawHandle_;

		/// Data lost flag.
		bool dataLost_;
		/// Data pending flag.
		bool dataPending_;
	};
}
#endif    /* EnnGPUObject_h__ */